package com.william.yun.yunliwuli.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.william.yun.yunliwuli.service.CoreService;
import com.william.yun.yunliwuli.service.GoodsService;

/**
 * 商品
 */
public class GoodsServiceImpl extends CoreService implements GoodsService {
    /**
     * 插入
     *
     * @param jsonObject
     * @param token
     * @return
     */
    @Override
    public JSONObject insertGoods(JSONObject jsonObject, String token) {
        String storeUuid = jsonObject.getString("storeUuid");
        return postJsonResult(jsonObject.getJSONArray("goods"), token, GOODS_URL.concat("?storeUuid=").concat(storeUuid));
    }



    /**
     * 删除
     *
     * @param jsonObject
     * @param token
     * @return
     */
    @Override
    public JSONObject removeGoods(JSONObject jsonObject, String token) {
        return deleteJsonResult(jsonObject, token, GOODS_URL);
    }

    /**
     * 修改
     *
     * @param jsonObject
     * @param token
     * @return
     */
    @Override
    public JSONObject updateGoods(JSONObject jsonObject, String token) {
        return putJsonResult(jsonObject, token, GOODS_URL);

    }

    /**
     * 推送单个商品
     *
     * @param jsonObject
     * @param token
     * @return
     */
    @Override
    public JSONObject brush(JSONObject jsonObject, String token) {
        String storeUuid = jsonObject.getString("storeUuid");
        return postJsonResult(jsonObject.getJSONObject("information"), token, GOODS_BRUSH.concat("?storeUuid=").concat(storeUuid));
    }

    /**
     * 获取商品信息
     *
     * @param jsonObject
     * @param token
     * @return
     */
    @Override
    public JSONObject getGoodsAll(JSONObject jsonObject, String token) {
        return getJsonResult(null, token, jsonToString(jsonObject, GOODS_ALL_URL));
    }

    /**
     * 系统批量导入商品
     *
     * @param jsonObject
     * @param token
     * @return
     */
    @Override
    public JSONObject postAdminGoods(JSONObject jsonObject, String token) {
        return postJsonResult(jsonObject, token, GOODS_ADMIN);
    }


}
